let result = document.getElementById('result');
let currentInput = '';

function appendNumber(num) {
    currentInput += num;
    result.value = currentInput;
}

function operator(op) {
    currentInput += op;
    result.value = currentInput;
}

function clearResult() {
    currentInput = '';
    result.value = '';
}

function calculate() {
    try {
        let expression = currentInput;
        let evaluated = eval(expression);
        result.value = evaluated;
        currentInput = evaluated;
    } catch (e) {
        result.value = 'Error';
    }
}